package io.kiki.sba.registry.common.model.metaserver;

import io.kiki.sba.registry.common.model.ServerData;
import lombok.Getter;

import java.io.Serializable;


@Getter
public class ProvideData implements Serializable {

    private final ServerData serverData;

    private final String dataInfoId;

    private final Long version;


    public ProvideData(ServerData serverData, String dataInfoId, Long version) {
        this.serverData = serverData;
        this.dataInfoId = dataInfoId;
        this.version = version;
    }

    public static String toString(ProvideData provideData) {
        if (provideData == null || provideData.getServerData() == null) {
            return null;
        }
        return (String) provideData.getServerData().getObject();
    }

    public static Integer toInteger(ProvideData provideData) {
        String obj = ProvideData.toString(provideData);
        return obj != null ? Integer.valueOf(obj) : null;
    }


}
